//
//  LoginController.swift
//  ExpressManager
//
//  Created by sheng on 2017/11/2.
//  Copyright © 2017年 sheng. All rights reserved.
//

import UIKit
import SnapKit

class LoginController: UIViewController, UITextFieldDelegate {
    
    @IBOutlet weak var logo: UIImageView!
   
    @IBOutlet weak var userInput: UITextField!
    
    @IBOutlet weak var passwordInput: UITextField!
    
    @IBOutlet weak var loginBtn: UIButton!
    
    @IBOutlet weak var checkbox: CheckBox!
    
    @IBOutlet weak var checkLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.logo.snp.makeConstraints { (make) -> Void in
            make.top.equalTo(self.view.snp.top).offset(120)
            make.centerX.equalTo(self.view)
            make.height.equalTo(80)
            make.width.equalTo(80)
        }

        
        let imgLock1 =  UIImageView(frame:CGRect(x: 9, y: 9, width: 22, height: 22))
        imgLock1.image = UIImage(named:"iconfont-user")
        self.userInput.leftView = UIView(frame:CGRect(x: 0, y: 0, width: 40, height: 40))
        self.userInput.leftViewMode = UITextFieldViewMode.always
        self.userInput.leftView!.addSubview(imgLock1)
        
        self.userInput.snp.makeConstraints { (make) -> Void in
            make.left.equalTo(30)
            make.right.equalTo(-30)
            make.height.equalTo(40)
            make.top.equalTo(self.logo.snp.bottom).offset(20)
        }
        
        let imgLock2 =  UIImageView(frame:CGRect(x: 9, y: 9, width: 22, height: 22))
        imgLock2.image = UIImage(named:"iconfont-password")
        self.passwordInput.leftView = UIView(frame:CGRect(x: 0, y: 0, width: 40, height: 40))
        self.passwordInput.leftViewMode = UITextFieldViewMode.always
        self.passwordInput.leftView!.addSubview(imgLock2)
        
        self.passwordInput.snp.makeConstraints { (make) -> Void in
            make.left.equalTo(30)
            make.right.equalTo(-30)
            make.height.equalTo(40)
            make.top.equalTo(self.userInput.snp.bottom).offset(10)
        }
        
        
        self.loginBtn.layer.cornerRadius = 5
        self.loginBtn.layer.borderWidth = 0.5
        self.loginBtn.layer.borderColor = UIColor.lightGray.cgColor
        self.loginBtn.backgroundColor = UIColor.white
        
        self.loginBtn.snp.makeConstraints { (make) -> Void in
            make.height.equalTo(40)
            make.left.equalTo(60)
            make.right.equalTo(-60)
            make.top.equalTo(self.checkbox.snp.bottom).offset(20)
        }
        
        self.checkbox.snp.makeConstraints { (make) -> Void in
            make.height.equalTo(22)
            make.width.equalTo(22)
            make.left.equalTo(30)
            make.top.equalTo(self.passwordInput.snp.bottom).offset(8)
        }
        
        self.checkLabel.snp.makeConstraints { (make) -> Void in
            make.centerY.equalTo(self.checkbox)
            make.left.equalTo(60)
        }
        
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()

    }
    
    
    @IBAction func loginClick(_ sender: Any) {
        print(self.checkbox.isChecked)
    }
  
    
    
}

